package com.alibaba.citrus.cr.platform.enhance.facade.sls;

import com.aliyun.openservices.loghub.client.interfaces.ILogHubProcessor;
import com.aliyun.openservices.loghub.client.interfaces.ILogHubProcessorFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author: qiaojiange
 * @create: 2021/11/09
 * @Description 日志 hub处理工厂
 */
@Component
public class LogHubProcessorFactory implements ILogHubProcessorFactory, ApplicationContextAware {
    private ApplicationContext applicationContext;

    @Override
    public ILogHubProcessor generatorProcessor() {
        // 生成一个消费实例。
        return applicationContext.getBean(LogHubProcessor.class);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
